/////////////////////////////////////////////////////
//	File Name	:	"CBase.cpp"
//
//	Author Name	:	Mason Miller
//
//	Purpose		:	To contain all related data and functionality for our game objects.
/////////////////////////////////////////////////////

#include "CBase.h"
#include "..\Wrappers\CSGD_TextureManager.h"	//	Always include needed headers in cpp files whenever possible

CBase::CBase(void)
{
	m_uiRefCount = 1;	//	start with a reference to self
	SetPosX(0);
	SetPosY(0);
	SetVelX(0.0f);
	SetVelY(0.0f);
	SetWidth(0);
	SetHeight(0);
	SetImageID(-1);
}

CBase::~CBase(void)
{

}

void CBase::Update(float fElapsedTime)
{
	//	pos += vel		<- frame based
	//	pos += vel * dt	<- time based
	SetPosX(GetPosX() + (GetVelX() * fElapsedTime));
	SetPosY(GetPosY() + (GetVelY() * fElapsedTime));
}

void CBase::Render(void)
{
	CSGD_TextureManager::GetInstance()->Draw(GetImageID(),
											 (int)GetPosX(),
											 (int)GetPosY());
}

RECT CBase::GetRect(void)
{
	RECT rRect;

	rRect.left = (LONG)GetPosX();
	rRect.top = (LONG)GetPosY();
	rRect.right = (LONG)(GetWidth() + GetPosX());
	rRect.bottom = (LONG)(GetHeight() + GetPosY());

	return rRect;
}

bool CBase::CheckCollision(IBaseInterface* pBase)
{
	RECT rRect;
	if(IntersectRect(&rRect, &GetRect(), &pBase->GetRect()))
		return true;
	return false;
}